package com.ruoyi.StarStudio.Mapper;

import com.ruoyi.StarStudio.Domain.Zone;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ZoneMapper {

    @Select("select * from zone")
    public List<Zone> getAll();

    @Select("select zone_id from zone")
    public List<Integer> getZoneIdList();

    List<Zone> getList(Zone zone);

    @Select("select * from zone where zone_id = #{zoneId}")
    public Zone getById(int zoneId);

    @Insert("insert into zone values (null,#{zone_name}, #{zone_area}, #{zone_treeNum}, #{zone_treeVariety})")
    @Options(useGeneratedKeys = true,keyProperty = "zone_id",keyColumn = "zone_id")
    public void add(Zone zone);

    @Update("update zone set zone_name=#{zone_name},zone_area=#{zone_area},zone_treenum=#{zone_treeNum},zone_treevariety=#{zone_treeVariety} where zone_id = #{zone_id}")
    public void update(Zone zone);

    @Delete("delete from zone where zone_id = #{zoneId}")
    public void delete(Integer zoneId);

    @Select("select zone_name from zone where zone_id = #{zoneId}")
    public String getZoneNameByZoneId(int zoneId);

    @Select("select * from zone where zone_name = #{zoneName}")
    public Zone getByName(String zoneName);

    @Select("select zone_id from zone where zone_name = #{zoneName}")
    public int getZoneIdByZoneName(String zoneName);
}
